//
//  ECMineFeedBackViewController.m
//  Edu_iOS2018
//
//  Created by apple on 2018/1/6.
//  Copyright © 2018年 yanyan. All rights reserved.
//

#import "ECMineFeedBackViewController.h"
#import "UITextView+Placeholder.h"
#import "ECAudioPlayerView.h"

@interface ECMineFeedBackViewController ()

@end

@implementation ECMineFeedBackViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"意见反馈";
    self.view.backgroundColor = [UIColor colorWithHexString:@"#F5F5F5"];
    
    UIView *topBaseview = [[UIView alloc]init];
    [self.view addSubview:topBaseview];
    topBaseview.backgroundColor = [UIColor whiteColor];
    
    UITextView *textview = [[UITextView alloc]init];
    [topBaseview addSubview:textview];
    textview.placeholder = @"请详细描述您的问题或建议,我们将及时跟进解决.(建议添加相关问题截图)";
    textview.placeholderColor = [UIColor colorWithHexString:@"#cccccc"];
    textview.font = [UIFont systemFontOfSize:16*kPercentage];
    
    UIButton *imageBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [topBaseview addSubview:imageBtn];
    [imageBtn addTarget:self action:@selector(imageBtn_click) forControlEvents:UIControlEventTouchUpInside];
    [imageBtn setImage:[UIImage imageNamed:@"Mine_feedbackImage"] forState:0];
    
    UILabel *tipLab = [[UILabel alloc]init];
    [topBaseview addSubview:tipLab];
    tipLab.text = @"可上传图片";
    tipLab.textColor = [UIColor colorWithHexString:@"#CCCCCC"];
    
    WeakSelf(weakSelf);
    [topBaseview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.view.mas_top);
        make.width.equalTo(weakSelf.view.mas_width);
        make.height.equalTo(topBaseview.mas_width).multipliedBy(640.f/1080.f);
    }];
    
    [textview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(topBaseview.mas_top);
        make.left.equalTo(topBaseview.mas_left).offset(kProportion_Width(50));
        make.right.equalTo(topBaseview.mas_right).offset(-kProportion_Width(50));
        make.bottom.equalTo(imageBtn.mas_top).offset(-20);
    }];
    
    [imageBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(textview.mas_bottom).offset(20);
        make.bottom.equalTo(topBaseview.mas_bottom).offset(-kProportion_Height(40));
        make.left.equalTo(topBaseview.mas_left).offset(kProportion_Width(50));
        make.width.and.height.equalTo(@(kProportion_Width(234)));
    }];
    
    [tipLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(imageBtn.mas_right).offset(kProportion_Width(24));
        make.centerY.equalTo(imageBtn.mas_centerY);
        make.width.equalTo(@100);
        make.height.equalTo(@18);
    }];
    
    UIView *bottomView = [[UIView alloc]init];
    [self.view addSubview:bottomView];
    bottomView.backgroundColor = [UIColor whiteColor];
    
    UILabel *phoneLab = [[UILabel alloc]init];
    [bottomView addSubview:phoneLab];
    phoneLab.text = @"手机号/邮箱/QQ号";
    phoneLab.textColor = [UIColor colorWithHexString:@"#808080"];
    phoneLab.font = [UIFont systemFontOfSize:15*kPercentage];
    
    UITextField *phoneTF = [[UITextField alloc]init];
    [bottomView addSubview:phoneTF];
    phoneTF.placeholder = @"手机号/邮箱/QQ号(选填,方便我们联系您)";
    
    [bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(topBaseview.mas_bottom).offset(kProportion_Height(30));
        make.width.equalTo(topBaseview.mas_width);
        make.left.equalTo(topBaseview.mas_left);
        make.height.equalTo(bottomView.mas_width).multipliedBy(135.f/1080.f);
    }];
    
    [phoneLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(imageBtn.mas_left);
        make.centerY.equalTo(bottomView.mas_centerY);
        make.width.equalTo(@(kProportion_Width(430)));
        make.height.equalTo(@0);
    }];
    
    [phoneTF mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(phoneLab.mas_left);
        make.centerY.equalTo(bottomView.mas_centerY);
        make.right.equalTo(bottomView.mas_right);
        make.height.equalTo(@18);
    }];

    
    ECUButton *submitBtn = [ECUButton buttonWithType:UIButtonTypeCustom];
    [self.view addSubview:submitBtn];
    [submitBtn setTitle:@"提交" forState:0];
    [submitBtn setBackgroundImage:[UIImage imageNamed:@"flatButton_colorSelected"] forState:0];
    [submitBtn addTarget:self action:@selector(submitBtn_click) forControlEvents:UIControlEventTouchUpInside];
    
    [submitBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.view.mas_left).offset(kProportion_Width(60));
        make.right.equalTo(weakSelf.view.mas_right).offset(-kProportion_Width(60));
        make.top.equalTo(bottomView.mas_bottom).offset(kProportion_Height(60));
        make.height.equalTo(bottomView.mas_height);
    }];
}

-(void)submitBtn_click{
    ECAudioPlayerView *audioview = [[ECAudioPlayerView alloc]init];
    audioview.frame = CGRectMake(0, 0, kScreenWidth, kScreenWidth/16*9);
    [self.view addSubview:audioview];
}

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [self.view endEditing:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
